<template>
    <el-container>
        <el-header>
            <HeaderComponent />
        </el-header>
        <el-main class="el-main-container">
          <div class="loginbox">
            <div class="jarallax-bg" > </div>
          </div>
          <div class="py-5">
            <el-row :gutter="20" style="margin-top: 40px;margin-left: 100px; margin-right: 100px;">
              <el-col :span="8" v-for="(record, index) in records" :key="index">
                <el-card shadow="hover" class="post-item">
                  <div class="image-holder zoom-effect">
                      <img :src="'../images/'+record.blogImg" alt="post" class="card-img-top">
                  </div>
                  <div class="card-body">
                    <div class="post-meta d-flex text-uppercase gap-3 my-2 align-items-center">
                      <div class="meta-date"><i class="el-icon-date"></i>{{record.blogDate}}</div>
                    </div>
                    <div class="post-header">
                      <h3 class="post-title">{{record.blogTitle}}</h3>
                      <p>{{record.blogDetails}}</p>
                    </div>
                  </div>
                </el-card>
              </el-col>
            </el-row>
           
          </div>
        </el-main>
        <el-footer>
          <FooterComponent />
        </el-footer>
    </el-container>
</template>

<script>
import { getbloglist } from '@/api/api';

export default {
  name: 'blog',
  components: {
    HeaderComponent: () => import('@/pages/header.vue'),
    FooterComponent: () => import('@/pages/demo.vue')
  },
  data() {
    return {
        records:[],
        pageNum: 1, // 当前页码
        pageSize: 9, 
        total: 0
    };
  },
  methods:{
    getbolg(){
      this.pageNum=this.pageNum
      const that=this;
      getbloglist(this.pageNum,this.pageSize).then(res=>{
       that.records=res.data.records;
       console.log(res.data.records);
       that.total=res.data.total
       console.log(this.records);
        console.log(res);
        
      })
    }
  },
  created(){
    this.getbolg();
  }
}

</script>

<style scoped>

.el-main-container{
    margin: 0;
    padding: 0;
}

 html{
    margin: 0;
    padding: 0;
 }
 .loginbox{
    height: 300px;
    background-color: #f4d16e;
    background-image:url(../images/banner-1.jpg);
    background-repeat: no-repeat;
    background-size: cover;
    margin: 0 auto;
  }
  
  .jarallax-bg{
    width: 1600px;
    height: 300px;
  }
  .post-item {
  margin-bottom: 20px;
}

.image-holder img {
  width: 100%;
  height: auto;
}

.card-body {
  padding: 15px;
}

.post-meta {
  font-size: 0.9em;
}

.meta-date, .meta-categories {
  display: flex;
  align-items: center;
}

.meta-date i, .meta-categories i {
  margin-right: 5px;
}

.post-title {
  font-size: 1.2em;
  margin: 10px 0;
}

.post-title a {
  color: #333;
  text-decoration: none;
}

.post-title a:hover {
  color: #007bff;
}
</style>